home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / Miracle C Compiler / miricleC compiler.msi / Instal01.cab / _8E868807CED74BDBAEF9D791A4CF3AAF < prev    next >
Encoding:
Text File  |  2001-08-09  |  1.9 KB  |  88 lines

  1. #include <math.h>
  2.  
  3. #include <stdio.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6. #include <system.h>
  7. #include <stdlib.h>
  8.  
  9. void dodscan(), dologexp();
  10.  
  11. int main(int argc, char **argv)
  12. {
  13.    int i;
  14.    char rs[50], *ep;
  15.  
  16.    for(i=0; i<argc; i++)
  17.       printf("%d %s; ",i,argv[i]);
  18.  
  19. printf("\nnow the ints\t");
  20.    itoa(argc,rs,10);    printf("(%s) ",rs);
  21.    itoa(1001,rs,10);    printf("(%s) ",rs);
  22.    itoa(1001,rs,8);    printf("(%s) ",rs);
  23.    itoa(1001,rs,16);    printf("(%s) ",rs);
  24.  
  25.    itoa(-1001,rs,10);    printf("(%s) ",rs);
  26.    itoa(-101,rs,10);    printf("(%s) ",rs);
  27.    itoa(-1001,rs,16);    printf("(%s)\n",rs);
  28.  
  29. printf("now the longs\t");
  30.    ltoa(10001L,rs,10);    printf("(%s) ",rs);
  31.    ltoa(10001L,rs,8);    printf("(%s) ",rs);
  32.    ltoa(10001L,rs,16);    printf("(%s) ",rs);
  33.  
  34.    ltoa(-10001L,rs,10);    printf("(%s) ",rs);
  35.    ltoa(-101L,rs,10);    printf("(%s)\n",rs);
  36.  
  37. printf("now strtol   ");
  38.  
  39.    printf("%ld\t",strtol("-12345xyz",&ep,10));    printf("(%s)  ",ep);
  40.    printf("%ld\t",strtol("0xfAcE",&ep,16));    printf("%d\n",*ep);
  41.  
  42.    printf("%ld\t",strtoul("-12345xyz",&ep,10));    printf("(%s) ",ep);
  43.    printf("%ld\t",strtoul("0xfAcE",&ep,16));    printf("%d\n",*ep);
  44.  
  45. printf("now math    ");
  46.  
  47.    dodscan();
  48.    dologexp();
  49.  
  50.    return 0;
  51. }
  52.  
  53.  
  54.  
  55. void dodscan()
  56. {
  57.    FILE *fin;
  58.    double a;
  59.  
  60.    if((fin=fopen("ftest.txt","r"))==NULL)
  61.       {
  62.       printf("could not open ftest.txt\n");
  63.       exit(1);
  64.       }
  65.  
  66.    fscanf(fin,"%lf",&a);
  67.  
  68.    while(!feof(fin))
  69.       {
  70.       printf("got(%lg)\t",a);
  71.       fscanf(fin,"%lf",&a);
  72.       }
  73.  
  74.    fclose(fin);
  75.    return;
  76. }
  77.  
  78. void dologexp()
  79. {
  80.    printf("%lg %lg\t",pow(3.5,9.0),pow(-3.5,9.0));
  81.  
  82.    printf("%lg %lg\t",pow(2.0,0.0),pow(0.0,-2.0));
  83.    printf("%lg %lg\n",pow(2.3,1.0),pow(-2.1,2.1));
  84.  
  85.    printf("%lg %lg %lg\n",sinh(3.0),cosh(3.0),tanh(3.0));
  86.    printf("%lg %lg %lg\n",asinh(2.0),acosh(2.0),atanh(0.5));
  87. }
  88.